package com.jixi.controller;

import com.jixi.common.result.Result;
import com.jixi.pojo.dto.TeacherLoginDto;
import com.jixi.pojo.vo.SchoolLoginListVo;
import com.jixi.pojo.vo.TeacherVo;
import com.jixi.service.SchoolService;
import com.jixi.service.TeacherService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Tag(name = "班主任登录接口")
@RestController
@RequestMapping("/teacher")
public class TeacherController {
    @Autowired
    private TeacherService teacherService;
    @Autowired
    private SchoolService schoolService;
    /**
     * 登录学校列表选择
     *
     * @return 学校列表
     * */
    @GetMapping("/login/school/list")
    @Operation(summary = "登录学校列表选择")
    public Result SchoolList(){
        List<SchoolLoginListVo> schoolList = schoolService.loginSchoolList();
        return Result.success(schoolList);
    }
    /**
     * 班主任登录
     *
     * @param teacherLoginDto
     * @return 登录结果
     * */
    @PostMapping("/login")
    @Operation(summary = "班主任登录")
    public Result login(@RequestBody TeacherLoginDto teacherLoginDto) {
        teacherService.login(teacherLoginDto);
        return Result.success("登录成功");
    }
    /**
     * 班主任信息查询
     *
     * @return班主任信息
     * */
    @GetMapping("/info")
    @Operation(summary = "班主任信息")
    public Result<TeacherVo> getInfo(){
        TeacherVo teacherVo = teacherService.getTeacherDetail();
        return Result.success(teacherVo);
    }
}
